------------------------------------------------------------------------------------------------------------------------------------
--[[

            doer:PushEvent("hutao_event.stewer_cooking.start",{
                product = self.product,
                stewer = self,
                items = items,          -- {item_prefab1, item_prefab2, item_prefab3, item_prefab4}
            })

            self.__hutao_cooker:PushEvent("hutao_event.stewer_cooking.done",{
                product = self.product,
                stewer = self,
                items = self.__hutao_items,
            })

            doer:PushEvent("hutao_event.stewer_cooking.pre_harvest",{
                product = self.product,
                stewer = self,
            })

]]--
------------------------------------------------------------------------------------------------------------------------------------



AddComponentPostInit("stewer", function(self)

    self.__hutao_cooker = nil --- 记录烹饪者
    self.__hutao_items = {} --- 记录烹饪材料

    ---- 烹饪开始的时候
    local old_StartCooking = self.StartCooking
    self.StartCooking = function(self,doer,...)
        local start_flag = false
        if self.targettime == nil and self.inst.components.container ~= nil and self.inst.components.container:NumItems() == 4 then
            start_flag = true
            self.inst.components.container:ForEachItem(function(item)
                table.insert(self.__hutao_items,item.prefab)
            end)
            self.__hutao_cooker = doer
        end
        old_StartCooking(self,doer,...)
        if start_flag and doer and #self.__hutao_items == 4 then
            doer:PushEvent("hutao_event.stewer_cooking.start",{
                product = self.product,
                stewer = self,
                items = self.__hutao_items,
            })
        end
    end
    ---- 烹饪完成的时候
    self.inst:DoTaskInTime(0,function()
        
        local old_ondonecooking = self.ondonecooking or function ()    end
        self.ondonecooking = function(inst,...)
            if self.__hutao_cooker and self.__hutao_cooker:IsValid() then
                self.__hutao_cooker:PushEvent("hutao_event.stewer_cooking.done",{
                    product = self.product,
                    stewer = self,
                    items = self.__hutao_items,
                })
                self.__hutao_items = {}
                self.__hutao_cooker = nil
            end
            old_ondonecooking(inst,...)
        end

    end)

    ---- 烹饪采集的时候
    local old_Harvest = self.Harvest
    self.Harvest = function(self,doer,...)
        if self.done and doer then
            doer:PushEvent("hutao_event.stewer_cooking.pre_harvest",{
                product = self.product,
                stewer = self,
            })
        end
        return old_Harvest(self,doer,...)
    end


end)